.book-searcher-container {
  margin-left: 0.5rem;
  position: relative;
  width: 100%;

  @media (min-width: 768px) {
    margin-left: 1.25rem;
    max-width: 315px;
    transition: max-width 0.3s ease;
  }

  &:has(.search-iconfield.focused),
  &:has(.search-iconfield.has-results) {
    @media (min-width: 768px) {
      max-width: 100%;
    }
  }
}

.search-iconfield {
  width: 100%;

  @media (min-width: 640px) {
    display: flex;
  }

  @media (min-width: 768px) {
    transition: all 0.3s ease;
  }
}

.search-input {
  width: 100%;
  padding-right: 2.5rem;
  height: 2.5rem;
  line-height: 2.5rem;
  font-size: 1rem;
}

.clear-search-btn {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  display: none;

  @media (min-width: 1024px) {
    display: inline-flex;
  }
}

.search-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 0;
  width: 300px;
  background-color: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1),
  0 2px 4px -1px rgba(0, 0, 0, 0.06),
  0 10px 15px -3px rgba(0, 0, 0, 0.1);
  z-index: 1000;
  max-height: 70vh;
  overflow-y: auto;
  opacity: 0;
  height: 0;
  transform: translateY(-10px);
  transition: opacity 0.2s ease, transform 0.2s ease, height 0.2s ease;

  @media (min-width: 640px) {
    width: 100%;
    max-width: 600px;
  }

  &::-webkit-scrollbar {
    width: 8px;
  }

  &::-webkit-scrollbar-track {
    background: transparent;
  }

  &::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
  }

  &::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary-color);
  }
}

.search-dropdown.show {
  opacity: 1;
  height: auto;
  transform: translateY(0);
}

.search-dropdown-item {
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: background-color 0.2s ease;

  &:first-child {
    border-radius: 8px 8px 0 0;
  }

  &:last-child {
    border-radius: 0 0 8px 8px;

    ::ng-deep .p-divider {
      display: none;
    }
  }

  &:hover {
    background-color: var(--surface-hover);
  }

  &.no-results {
    padding: 2rem 1rem;
    text-align: center;
    color: var(--text-secondary-color);
    font-style: italic;
  }

  ::ng-deep .p-divider {
    margin: 0;

    &::before {
      border-top-color: var(--border-color);
      opacity: 0.5;
    }
  }
}

.search-item-content {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 1rem;
  width: 100%;
  padding: 0.75rem 1rem;
}

.search-book-cover {
  width: 50px;
  height: 67px;
  min-width: 50px;
  object-fit: cover;
  border-radius: 4px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  background-color: var(--surface-ground);
}

.search-book-details {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.search-book-title-container {
  display: flex;
  align-items: flex-start;
}

.search-book-name {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--text-color);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  word-break: break-word;
  margin: 0;
}

.search-book-meta-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.search-book-authors {
  font-size: 0.9rem;
  font-style: italic;
  color: var(--text-secondary-color);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin: 0;
  flex: 1;
  min-width: 0;
}

.search-book-year {
  font-size: 0.8rem;
  color: var(--text-secondary-color);
  background-color: var(--surface-ground);
  padding: 0.125rem 0.5rem;
  border-radius: 4px;
  white-space: nowrap;
  font-weight: 500;
}

.search-book-series {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 0.8rem;
  color: var(--primary-color);
  background-color: rgba(var(--primary-color-rgb, 59, 130, 246), 0.1);
  padding: 0.075rem 0.125rem;
  border-radius: 4px;
  width: fit-content;

  i {
    font-size: 0.75rem;
  }

  span {
    font-weight: 500;
  }
}

.search-book-metadata {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.metadata-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.8rem;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
  background-color: var(--surface-hover);
  color: var(--text-secondary-color);
  white-space: nowrap;

  i {
    font-size: 0.7rem;
  }

  &.series-badge {
    background-color: rgba(59, 130, 246, 0.1);
    color: rgb(59, 130, 246);
  }

  &.year-badge {
    background-color: rgba(34, 197, 94, 0.1);
    color: rgb(34, 197, 94);
  }
}
